package com.pgytesting.secondhandcar.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author : frosty0804@gmail.com
 * @version : v1.0
 * @projectName : SecondHandCar
 * @className : InterceptorConfig
 * @description : TODO(拦截器请求配置类)
 * @date : 2019/6/23 14:52
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {
    /**
     * {@inheritDoc}
     * <p>This implementation is empty.
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // /**表示拦截所有请求，然后全部转入loginInterceptor对象进行处理请求
        /**
         * 此处需要注意，如果是application配置的路径，则不需要写在此处
         * 拦截器只拦截被加载到容器中的路径
         */
        registry.addInterceptor(new Interceptor()).addPathPatterns("/**")
		        .excludePathPatterns("/admin/login")
                .excludePathPatterns("/getSMSCode", "/isLogin", "/loginOut")
                .excludePathPatterns("/user/login/login", "/user/login/register")
                .excludePathPatterns("/sales/login/login", "/sales/login/register");

        super.addInterceptors(registry);
    }

}
